#! /usr/bin/env python
# -*- coding: utf-8 -*-

# Some configuration guidance for YahMon, the poor man's monitoring script.
# For more info, see http://yahmon.googlecode.com/ .

# Logging configuration.
# Define a logger for all the sites, or use a different logger per site.
import logging
import logging.handlers
LOG_FILENAME = 'yahmon.log'
l = logging.getLogger('yahmon')
l.setLevel(logging.DEBUG)
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME,
                                               maxBytes=1048576,
                                               backupCount=5)
l.addHandler(handler)


# SMTP configuration
SMTP_SERVER = 'localhost'
SMTP_PORT = 25
SMTP_AUTHENTICATION_REQUIRED = False
SMTP_USER = ''  # Set SMTP username here if using AUTH.
SMTP_PWD = ''   # Set SMTP password here if using AUTH


# Message templates configuration.
#
# The template will be used to build the body of alert messages
# using %-based substitutions, as follows:
# message = template % (recipients, sender, url.upper(), url, outcome)
# Yes, this is a PITA. I'll do better soon.
MESSAGE_TEMPLATE = u"""To: %s
From: %s
Subject: ALERT! %s IS DOWN, MON.

Yah Mon, %s is down.
Mi dun feel bad, fren'.

%s

"""


# Error messages.
CONTENT_NOT_FOUND = u"Could not find mandatory content in response, Mon."
SERVER_NOT_RESPONDING = u"Babylon no respon, Mon."
SERVER_FAILED = u"The server couldn't handle the request, Mon."
CAUGHT_EXCEPTION = u"Caught exception, Mon."
ALL_IS_GOOD_MON = u"I-ree, Mon."


# Monitored sites configuration.
#
# Each site is defined as a dict where the key is the site URL (with http://)
#  and the keys define the different attributes of the site, including:
#
#  'content': a string to find in the response body.
#  'sender': a string, the 'from' address for e-mail alerts.
#  'recipients': a list of strings, the 'to' addresses for e-mail alerts.
#  'template': a template for the e-mail alert body.
#
# The alert message is built using %-based substitution as follows:
#  message = template % (recipients, sender, url.upper(), url, outcome)
# This is kind'of limited -- we'll think of something better soon.
SITES = {
    'http://www.example.com/': {
        'content': 'If better be in the response, Mon.',
        'sender': 'noreply@example.com',
        'recipients': ['dude@example.net', 'boss@example.org'],
        'template': MESSAGE_TEMPLATE,
        'logger': l,
        },
    # Add more sites here.
}
